<?php include "../public/header.php";?>
<?php include "../public/header_edit.php";?>
<link rel="stylesheet" type="text/css" href="/static/component/laytp/module/cityPicker/city-picker.css">
<style>
    #commentForm .main-container .short_table_list tbody{min-height: unset!important;}
</style>
<body id="optPage">
<form class="layui-form layui-form-pane" id="commentForm">
    <div class="page-title"><div class="page-title-con"><span id="flowsetname"></span><div class="move_title"></div><?php include "../public/subturn.php";?></div></div>
    <div class="main-container" style="padding-bottom: 500px!important;">

        <div class="block-generic">
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>申请人信息</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">申请人</label>
                        <div class="layui-input-block">
                            <input type="text" id="flowuser" readonly placeholder="请输入" autocomplete="off" class="layui-input readonly">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">申请部门</label>
                        <div class="layui-input-block">
                            <input type="text" id="flowdept" readonly placeholder="请输入" autocomplete="off" class="layui-input readonly">
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>工程负责人预收款信息</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">工程负责人</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="gofuer" class="layui-input gofuer" onclick="openPage('../public/choose_dealcom.php?dom=gofuer&page=hou_gongyu','80%','80%')">
                            <div class="choose_div" id="gofuer" key="0"></div>
                            <span class="choose_one" onclick="openPage('../public/choose_dealcom.php?dom=gofuer&page=hou_gongyu','80%','80%')"><i class="layui-icon layui-icon-search"></i></span>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">工程负责人联系电话</label>
                        <div class="layui-input-block">
                            <input type="text" name="gofutel" id="gofutel" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>工程负责人预收款资金池（单位：元）</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <table class="layui-table chuantable" lay-size="sm">
                        <thead>
                        <tr>
                            <th>累计预收款(元)</th>
                            <th>累计工程付款(元)</th>
                            <th>累计已收取(元)</th>
                            <th>其中暂扣合计(元)</th>
                            <th>暂扣解冻合计(元)</th>
                            <th>预留金额(元)</th>
                            <th>进项抵扣退税转入(元)</th>
                            <th>预收款可用余额(元)</th>
                        </tr>
                        </thead>
                        <tbody class="short_table_tbody">
                        <tr>
                            <td><span id="hougongyumoney"></span></td>
                            <td><span id="hougongzhimoneyqugoer"></span></td>
                            <td><span id="hougongyukoufee"></span></td>
                            <td><span id="qizankoufee"></span></td>
                            <td><span id="jiedongkoufee"></span></td>
                            <td><span id="yuliufee"></span></td>
                            <td><span id="hougongshuimoneygoquan"></span></td>
                            <td><span id="hougongyukeyong"></span></td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>




            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>本次预收款到账信息</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>款项摘要</label>
                        <div class="layui-input-block">
                            <input type="text" name="zhai" id="zhai" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>到账金额(元)</label>
                        <div class="layui-input-block">
                            <input type="text" name="money" id="money" placeholder="请输入" autocomplete="off" class="layui-input moneyinput">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label"><text>*</text>收款对象</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="duier" class="layui-input duier" onclick="openPage('../public/choose_dealcom.php?dom=duier&page=hou_gongyu2','80%','80%')">
                            <div class="choose_div" id="duier" key="1"></div>
                            <span class="choose_one" onclick="openPage('../public/choose_dealcom.php?dom=duier&page=hou_gongyu2','80%','80%')"><i class="layui-icon layui-icon-search"></i></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>到账方式</label>
                        <div class="layui-input-block">
                            <div id="incdaotype"></div>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>到账账户</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="accid" class="layui-input accid" onclick="openPage('../public/choose_account.php?dom=accid','80%','80%')">
                            <div class="choose_div" id="accid" key="1"></div>
                            <span class="choose_one" onclick="openPage('../public/choose_account.php?dom=accid','80%','80%')"><i class="layui-icon layui-icon-search"></i></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>到账日期</label>
                        <div class="layui-input-block">
                            <input type="text" name="dt" id="dt" readonly placeholder="请选择" clearable  autocomplete="off" class="layui-input bdate_ymd">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">通知业务员</label>
                        <div class="layui-input-block">
                            <div class="tanxian">
                                <div class="tanxianclick" onclick="openPage('../public/choose_userpart.php?dom=tonger&type=user&single=2', '770px', '490px');"></div>
                                <div class="tanxiannei" id="tonger"></div>
                            </div>
                            <div class="tancheckdiv"><div class="tancheck" onclick="openPage('../public/choose_userpart.php?dom=tonger&type=user&single=2', '770px', '490px');"><i class="layui-icon layui-icon-search"></i></div></div>
                            <div id="tonger_tanerror" class="tanerrormsg"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">用途说明</label>
                        <div class="layui-input-block">
                            <input type="text" name="yong" id="yong" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">备注</label>
                        <div class="layui-input-block">
                            <textarea id="explain" name="explain" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">关联流程</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="flowrelas" class="layui-input flowrelas" onclick="openPage('../public/choose_flowrelas.php?dom=flowrelas','80%','80%');">
                            <div class="choose_div" id="flowrelas" key="1"></div>
                            <span class="choose_one" onclick="openPage('../public/choose_flowrelas.php?dom=flowrelas','80%','80%');"><i class="layui-icon layui-icon-search"></i></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-hide" id="advanersDiv">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">预审人</label>
                        <div class="layui-input-block relative">
                            <div class="tanxian">
                                <div class="tanxianclick" onclick="openPage('../public/choose_userpart.php?dom=advaners&type=user&single=2','770px','490px');"></div>
                                <div class="tanxiannei" id="advaners"></div>
                            </div>
                            <div class="tancheckdiv"><div class="tancheck" onclick="openPage('../public/choose_userpart.php?dom=advaners&type=user&single=2','770px','490px');"><i class="layui-icon layui-icon-search"></i></div></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-hide" id="nexterDiv">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label"><text>*</text>指定下一步审核人</label>
                        <div class="layui-input-block relative">
                            <div class="tanxian">
                                <div class="tanxianclick" onclick="openPage('../public/choose_userpart.php?dom=nexter&type=user&single=1','770px','490px');"></div>
                                <div class="tanxiannei" id="nexter"></div>
                            </div>
                            <div class="tancheckdiv"><div class="tancheck" onclick="openPage('../public/choose_userpart.php?dom=nexter&type=user&single=1','770px','490px');"><i class="layui-icon layui-icon-search"></i></div></div>
                        </div>
                    </div>
                </div>
            </div>
            <?php include '../public/upinfo.php'?>
        </div>

        <div class="block-generic">
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>收取信息</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label"><text>*</text>本次回款是否收取</label>
                        <div class="layui-input-block">
                            <select id="iskou" name="iskou" lay-filter="iskou">
                                <option value="">请选择</option>
                                <option value="是">是</option>
                                <option value="否">否</option>
                            </select>
                            <p class="error" id="iskou_error" style="margin: 0;"></p>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-hide koushi">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label"><text>*</text>选择本次收取款项类型</label>
                        <div class="layui-input-block">
                            <div class="radio-block">
                                <input type="checkbox" name="koulei" lay-filter="koulei" lay-skin="primary" value="fuwu" title="待收取劳务分包服务费">
                                <input type="checkbox" name="koulei" lay-filter="koulei" lay-skin="primary" value="shuifei" title="待收取税款(含利息)">
                                <input type="checkbox" name="koulei" lay-filter="koulei" lay-skin="primary" value="gongjie" title="待收取工程负责人借款(含利息)">
                                <input type="checkbox" name="koulei" lay-filter="koulei" lay-skin="primary" value="kuaifei" title="待收取快递费">
                                <input type="checkbox" name="koulei" lay-filter="koulei" lay-skin="primary" value="qifei" title="直接收取">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-hide koushi">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">本次收取合计(元)</label>
                        <div class="layui-input-block">
                            <input type="text" name="koufee" id="koufee" placeholder="明细自动合计" readonly autocomplete="off" class="layui-input moneyinput disabled">
                        </div>
                    </div>
                </div>
            </div>
        </div>



        <div class="block-generic layui-hide fuwu_list_info">
            <div class="layui-form-item height_auto">
                <div class="short_table_list" key="11">
                    <div class="opt-btn-group">
                        <div><span>收取明细-待收取劳务分包服务费</span></div>
                        <div>
                            <button type="button" onclick="choose_koulei_fuwu()" class="layui-btn layui-btn-sm layui-btn-primary mingxibtn">选择待扣劳务分包服务费</button>
                            <button type="button" class="layui-btn layui-btn-sm layui-btn-primary mingxibtn short_table_del_row">删除行</button>
                            <button type="button" class="layui-btn layui-btn-sm layui-btn-primary mingxibtn short_table_del_all">删除全部</button>
                        </div>
                    </div>
                    <table class="layui-table" lay-size="sm">
                        <thead>
                        <tr>
                            <th width="45">序号</th>
                            <th>款项类型</th>
                            <th>费用所属工程名称</th>
                            <th><text>*</text>本次收取(元)</th>
                            <th>收取性质</th>
                            <th>收取标准</th>
                            <th>款项说明</th>
                            <th>合同价(元)</th>
                            <th>工程结算金额(元)</th>
                            <th>劳务分包服务费率(%)</th>
                            <th>累计应收取(元)</th>
                            <th>累计已收取(元)</th>
                            <th>待收取(元)</th>
                        </tr>
                        </thead>
                        <tbody class="short_table_tbody" id="fuwu_list"></tbody>
                    </table>
                    <div class="listerror">提示：<span></span></div>
                </div>
            </div>
        </div>

        <div class="block-generic layui-hide shuifei_list_info">
            <div class="layui-form-item height_auto">
                <div class="short_table_list" key="12">
                    <div class="opt-btn-group">
                        <div><span>收取明细-待收取税款保证金(含利息)</span></div>
                        <div>
                            <button type="button" onclick="choose_koulei_shuifei()" class="layui-btn layui-btn-sm layui-btn-primary mingxibtn">选择待扣收税款保证金及利息</button>
                            <button type="button" class="layui-btn layui-btn-sm layui-btn-primary mingxibtn short_table_del_row">删除行</button>
                            <button type="button" class="layui-btn layui-btn-sm layui-btn-primary mingxibtn short_table_del_all">删除全部</button>
                        </div>
                    </div>
                    <table class="layui-table" lay-size="sm">
                        <thead>
                        <tr>
                            <th width="45">序号</th>
                            <th>款项类型</th>
                            <th>费用所属工程名称</th>
                            <th><text>*</text>本次收取(元)</th>
                            <th>收取性质</th>
                            <th>收取标准</th>
                            <th>款项说明</th>
                            <th>税款保证金承诺书名称</th>
                            <th>申请日期</th>
                            <th>销项票开票金额(元)</th>
                            <th>开票日期</th>
                            <th>税款保证金金额((元)</th>
                            <th>收取状态</th>
                        </tr>
                        </thead>
                        <tbody class="short_table_tbody" id="shuifei_list"></tbody>
                    </table>
                    <div class="listerror">提示：<span></span></div>
                </div>
            </div>
        </div>

        <div class="block-generic layui-hide gongjie_list_info">
            <div class="layui-form-item height_auto">
                <div class="short_table_list" key="13">
                    <div class="opt-btn-group">
                        <div><span>收取明细-待收取工程负责人借款(含利息)</span></div>
                        <div>
                            <button type="button" onclick="choose_koulei_gongjie()" class="layui-btn layui-btn-sm layui-btn-primary mingxibtn">选择工程负责人待还借款本金及利息</button>
                            <button type="button" class="layui-btn layui-btn-sm layui-btn-primary mingxibtn short_table_del_row">删除行</button>
                            <button type="button" class="layui-btn layui-btn-sm layui-btn-primary mingxibtn short_table_del_all">删除全部</button>
                        </div>
                    </div>
                    <table class="layui-table" lay-size="sm">
                        <thead>
                        <tr>
                            <th width="45">序号</th>
                            <th>款项类型</th>
                            <th><text>*</text>利息优惠(元)</th>
                            <th><text>*</text>本次收取本金(元)</th>
                            <th><text>*</text>本次收取利息(元)</th>
                            <th><text>*</text>本次收取合计(元)</th>
                            <th>收取性质</th>
                            <th>收取标准</th>
                            <th>款项说明</th>
                            <th>合同编号</th>
                            <th>出借方</th>
                            <th>放款到账金额(元)</th>
                            <th>放款日期</th>
                            <th>借款周期数</th>
                            <th>待还本金(元)</th>
                            <th>待还利息(元)</th>
                            <th>待还合计(元)</th>
                        </tr>
                        </thead>
                        <tbody class="short_table_tbody" id="gongjie_list"></tbody>
                    </table>
                    <div class="listerror">提示：<span></span></div>
                </div>
            </div>
        </div>

        <div class="block-generic layui-hide kuaifei_list_info">
            <div class="layui-form-item height_auto">
                <div class="short_table_list" key="14">
                    <div class="opt-btn-group">
                        <div><span>收取明细-待收取快递费</span></div>
                        <div>
                            <button type="button" onclick="choose_koulei_kuaifei()" class="layui-btn layui-btn-sm layui-btn-primary mingxibtn">选择待扣快递费</button>
                            <button type="button" class="layui-btn layui-btn-sm layui-btn-primary mingxibtn short_table_del_row">删除行</button>
                            <button type="button" class="layui-btn layui-btn-sm layui-btn-primary mingxibtn short_table_del_all">删除全部</button>
                        </div>
                    </div>
                    <table class="layui-table" lay-size="sm">
                        <thead>
                        <tr>
                            <th width="45">序号</th>
                            <th>款项类型</th>
                            <th>费用所属工程名称</th>
                            <th><text>*</text>本次收取(元)</th>
                            <th>收取性质</th>
                            <th>收取标准</th>
                            <th>款项说明</th>
                            <th>收寄类型</th>
                            <th>运单号</th>
                            <th>收寄日期</th>
                            <th>付款方式</th>
                            <th>快递费用(元)</th>
                            <th>收取状态</th>
                        </tr>
                        </thead>
                        <tbody class="short_table_tbody" id="kuaifei_list"></tbody>
                    </table>
                    <div class="listerror">提示：<span></span></div>
                </div>
            </div>
        </div>

        <div class="block-generic layui-hide qifei_list_info">
            <div class="layui-form-item height_auto">
                <div class="short_table_list" key="15">
                    <div class="opt-btn-group">
                        <div><span>收取明细-直接收取</span></div>
                        <div>
                            <button type="button" class="layui-btn layui-btn-sm layui-btn-primary mingxibtn short_table_add_row">插入行</button>
                            <button type="button" class="layui-btn layui-btn-sm layui-btn-primary mingxibtn short_table_del_row">删除行</button>
                            <button type="button" class="layui-btn layui-btn-sm layui-btn-primary mingxibtn short_table_del_all">删除全部</button>
                        </div>
                    </div>
                    <table class="layui-table" lay-size="sm">
                        <thead>
                        <tr>
                            <th width="45">序号</th>
                            <th>款项类型</th>
                            <th>费用所属工程名称</th>
                            <th><text>*</text>本次收取(元)</th>
                            <th><text>*</text>收取性质</th>
                            <th>收取标准</th>
                            <th>款项说明</th>
                        </tr>
                        </thead>
                        <tbody class="short_table_tbody" id="qifei_list"></tbody>
                    </table>
                    <div class="listerror">提示：<span></span></div>
                </div>
            </div>
        </div>

    </div>
</form>
<script>

    $("#commentForm").validate({
        rules: {
            zhai: {required: true},
            money: {required: true},
            dt: {required: true},
        },
        messages:{
            zhai: {required: "请输入"},
            money: {required: "请输入"},
            dt: {required: "请选择"},
        }
    });


    function choose_koulei_fuwu(){
        var gofuer = get_choose_val('gofuer');
        if(!gofuer){
            facade.error("请先选择工程负责人");return false;
        }
        openPage('../hou_gonghui/koulei_fuwu.php?page=hou_gonghui&choose_type=checkbox&gofuer='+encodeURI(gofuer),'80%','80%');
    }
    function choose_koulei_shuifei(){
        var gofuer = get_choose_val('gofuer');
        if(!gofuer){
            facade.error("请先选择工程负责人");return false;
        }
        var daodt = $("#dt").val();
        if(!daodt){
            facade.error("请先选择到账日期");return false;
        }
        openPage('../hou_gonghui/koulei_shuifei.php?page=hou_gonghui&choose_type=checkbox&gofuer='+encodeURI(gofuer)+'&daodt='+daodt,'80%','80%');
    }
    function choose_koulei_gongjie(){
        var gofuer = get_choose_val('gofuer');
        if(!gofuer){
            facade.error("请先选择工程负责人");return false;
        }
        var daodt = $("#dt").val();
        if(!daodt){
            facade.error("请先选择到账日期");return false;
        }
        openPage('../hou_gonghui/koulei_gongjie.php?page=hou_gonghui&choose_type=checkbox&gofuer='+encodeURI(gofuer)+'&daodt='+daodt,'80%','80%');
    }
    function choose_koulei_kuaifei(){
        var gofuer = get_choose_val('gofuer');
        if(!gofuer){
            facade.error("请先选择工程负责人");return false;
        }
        openPage('../hou_gonghui/koulei_kuaifei.php?page=hou_gonghui&choose_type=checkbox&gofuer='+encodeURI(gofuer),'80%','80%');
    }



    function choose_engin_one(obj){
        var gofuer = get_choose_val('gofuer');
        if(!gofuer){
            facade.error("请先选择工程负责人");return false;
        }
        var domkey = $(obj).parents('tr').index();
        openPage('../public/choose_engin.php?page=hou_gonghui_one'+'&bengofuer='+encodeURI(gofuer)+'&domkey='+domkey,'80%','80%');
    }


    layui.use(['laytp', 'form'], function() {
        var form = layui.form, layer = layui.layer;
        render_input_attr();

        facade.ajax({type: 'get', url: ask_flowdata_add_hou_gongyu}).done(function(res){
            if (res.code === 2000) {
                var data = res.data;
                $("#flowsetname").text(data.flowsetname);
                $("#flowuser").val(data.flowuser);
                $("#flowdept").val(data.flowdept);
                if(data.isadvan){
                    $("#advanersDiv").removeClass('layui-hide');
                }
                if(data.isnext){
                    $("#nexterDiv").removeClass('layui-hide');
                }


                xmselect_dan('incdaotype', res.data.incdaotype, '', function (res) {
                    if(res.arr && res.arr.length > 0){
                        $("#incdaotype").find('xm-select').removeClass('error');
                    }else{
                        $("#incdaotype").find('xm-select').addClass('error');
                    }
                });

                short_table_opt_func('', 11);
                short_table_opt_func('', 12);
                short_table_opt_func('', 13);
                short_table_opt_func('', 14);

                var listAddStr = '';
                listAddStr += '<tr>';
                listAddStr += '<td style="width: 45px">1</td>';
                listAddStr += '<td><div class="houkoulei"></div></td>';
                listAddStr += '<td><input type="text" enginid="0" onclick="choose_engin_one(this)" readonly value="" class="layui-input enginid disabled"></td>';
                listAddStr += '<td><input type="number" class="layui-input koufee"></td>';
                listAddStr += '<td>';
                listAddStr += '<select class="layui-select kouxing">';
                listAddStr += '<option value="">请选择</option>';
                listAddStr += '<option value="实扣">实扣</option>';
                listAddStr += '<option value="暂扣">暂扣</option>';
                listAddStr += '</select>';
                listAddStr += '</td>';
                listAddStr += '<td><input type="text" class="layui-input shoubiao"></td>';
                listAddStr += '<td><input type="text" class="layui-input explain"></td>';
                listAddStr += '</tr>';
                short_table_opt_func(listAddStr, 15, {name:'houkoulei', data:res.data.houkoulei, value:''});


                public_upload_file_load('upload_files', res.data.files);
                render_date();
                render_from();
                initParseMoney();
            }
        });

        form.on('select(iskou)', function(data){
            if(data.value == ''){
                $('#iskou_error').show().text('请选择');
                $('#iskou_error').parent().find('input').addClass('select_error');
            }else{
                $('#iskou_error').hide();
                $('#iskou_error').parent().find('input').removeClass('select_error');
            }

            if(data.value == '是'){
                $(".koushi").removeClass('layui-hide');
            }else{
                $(".koushi").addClass('layui-hide');
            }
        });

        form.on('checkbox(koulei)', function(data){
            var arr = get_checkbox_value('koulei');
            if(in_array('fuwu', arr)){
                $(".fuwu_list_info").removeClass('layui-hide');
            }else{
                $(".fuwu_list_info").addClass('layui-hide');
            }
            if(in_array('shuifei', arr)){
                $(".shuifei_list_info").removeClass('layui-hide');
            }else{
                $(".shuifei_list_info").addClass('layui-hide');
            }
            if(in_array('gongjie', arr)){
                $(".gongjie_list_info").removeClass('layui-hide');
            }else{
                $(".gongjie_list_info").addClass('layui-hide');
            }
            if(in_array('kuaifei', arr)){
                $(".kuaifei_list_info").removeClass('layui-hide');
            }else{
                $(".kuaifei_list_info").addClass('layui-hide');
            }
            if(in_array('qifei', arr)){
                $(".qifei_list_info").removeClass('layui-hide');
            }else{
                $(".qifei_list_info").addClass('layui-hide');
            }
        });

        form.on('submit(add)', function(data){
            data.field.isturn = $(this).attr('key') || 0;
            data.field.flowrelas = get_choose_val('flowrelas');
            data.field.advaners = tan_tags_getvalue("#advaners", 'user');
            data.field.nexter = tan_tags_getvalue("#nexter", 'user');


            data.field.gofuer = get_choose_val('gofuer');
            data.field.accid = get_choose_val('accid');
            data.field.koulei = get_checkbox_value('koulei').join(',');
            data.field.tonger = tan_tags_getvalue("#tonger", 'user');
            data.field.duier = get_choose_val('duier');

            if(data.field.isturn > 0){
                var validRes = $("#commentForm").valid();

                formValid('gofuer');
                if(data.field.gofuer == undefined || !data.field.gofuer){
                    validRes = false;
                }

                formValid('duier');
                if(data.field.duier == undefined || !data.field.duier){
                    validRes = false;
                }

                if(!data.field.incdaotype){
                    $("#incdaotype").find('xm-select').addClass('error');
                    validRes = false;
                }else{
                    $("#incdaotype").find('xm-select').removeClass('error');
                }

                formValid('accid');
                if(data.field.accid == undefined || !data.field.accid){
                    validRes = false;
                }

                if(data.field.iskou == ''){
                    $('#iskou_error').show().text('请选择');
                    $('#iskou_error').parent().find('input').addClass('select_error');
                    validRes = false;
                }else{
                    $('#iskou_error').hide();
                    $('#iskou_error').parent().find('input').removeClass('select_error');
                }

                if(!validRes){return false;}



            }



            var fuwu_list = [''];
            try {
                $('#fuwu_list tr').each(function (i) {
                    var enginid = $(this).find('.name').attr('enginid');
                    var houkoulei = $(this).find('.houkoulei').attr('houkoulei');
                    var koufee = $(this).find('.koufee').val();
                    var kouxing = $(this).find('.kouxing').val();
                    var shoubiao = $(this).find('.shoubiao').val();
                    var explain = $(this).find('.explain').val();

                    var index = i + 1;
                    if(data.field.isturn > 0){
                        if(!koufee){
                            throw new Error('第'+index+'行，请输入本次收取');
                        }
                    }

                    fuwu_list.push({
                        enginid:enginid,
                        houkoulei:houkoulei,
                        koufee:koufee,
                        kouxing:kouxing,
                        shoubiao:shoubiao,
                        explain:explain,
                    });
                });
            } catch(e) {
                $(".fuwu_list_info .listerror").find('span').text(e.message);
                $(".fuwu_list_info .listerror").show();
                return false;
            }
            $(".fuwu_list_info .listerror").hide();
            data.field.fuwu_list = fuwu_list;



            var shuifei_list = [''];
            try {
                $('#shuifei_list tr').each(function (i) {
                    var shuiid = $(this).find('.name').attr('shuiid');
                    var houkoulei = $(this).find('.houkoulei').attr('houkoulei');
                    var koufee = $(this).find('.koufee').val();
                    var kouxing = $(this).find('.kouxing').val();
                    var shoubiao = $(this).find('.shoubiao').val();
                    var explain = $(this).find('.explain').val();

                    var index = i + 1;
                    if(data.field.isturn > 0){

                    }

                    shuifei_list.push({
                        shuiid:shuiid,
                        houkoulei:houkoulei,
                        koufee:koufee,
                        kouxing:kouxing,
                        shoubiao:shoubiao,
                        explain:explain,
                    });
                });
            } catch(e) {
                $(".shuifei_list_info .listerror").find('span').text(e.message);
                $(".shuifei_list_info .listerror").show();
                return false;
            }
            $(".shuifei_list_info .listerror").hide();
            data.field.shuifei_list = shuifei_list;




            var gongjie_list = [''];
            try {
                $('#gongjie_list tr').each(function (i) {
                    var tiaoid = $(this).find('.number').attr('tiaoid');
                    var houkoulei = $(this).find('.houkoulei').attr('houkoulei');
                    var youfee = $(this).find('.youfee').val();
                    var kouben = $(this).find('.kouben').val();
                    var kouli = $(this).find('.kouli').val();
                    var koufee = $(this).find('.koufee').val();
                    var kouxing = $(this).find('.kouxing').val();
                    var shoubiao = $(this).find('.shoubiao').val();
                    var explain = $(this).find('.explain').val();

                    var index = i + 1;
                    if(data.field.isturn > 0){
                        if(!youfee){
                            throw new Error('第'+index+'行，请输入利息优惠');
                        }
                    }

                    gongjie_list.push({
                        tiaoid:tiaoid,
                        houkoulei:houkoulei,
                        youfee:youfee,
                        kouben:kouben,
                        kouli:kouli,
                        koufee:koufee,
                        kouxing:kouxing,
                        shoubiao:shoubiao,
                        explain:explain,
                    });
                });
            } catch(e) {
                $(".gongjie_list_info .listerror").find('span').text(e.message);
                $(".gongjie_list_info .listerror").show();
                return false;
            }
            $(".gongjie_list_info .listerror").hide();
            data.field.gongjie_list = gongjie_list;


            var kuaifei_list = [''];
            try {
                $('#kuaifei_list tr').each(function (i) {
                    var kuaiid = $(this).find('.enginname').attr('kuaiid');
                    var kuaitype = $(this).find('.enginname').attr('kuaitype');
                    var houkoulei = $(this).find('.houkoulei').attr('houkoulei');
                    var koufee = $(this).find('.koufee').val();
                    var kouxing = $(this).find('.kouxing').val();
                    var shoubiao = $(this).find('.shoubiao').val();
                    var explain = $(this).find('.explain').val();

                    var index = i + 1;
                    if(data.field.isturn > 0){

                    }

                    kuaifei_list.push({
                        kuaiid:kuaiid,
                        kuaitype:kuaitype,
                        houkoulei:houkoulei,
                        koufee:koufee,
                        kouxing:kouxing,
                        shoubiao:shoubiao,
                        explain:explain,
                    });
                });
            } catch(e) {
                $(".kuaifei_list_info .listerror").find('span').text(e.message);
                $(".kuaifei_list_info .listerror").show();
                return false;
            }
            $(".kuaifei_list_info .listerror").hide();
            data.field.kuaifei_list = kuaifei_list;


            var qifei_list = [''];
            try {
                $('#qifei_list tr').each(function (i) {
                    var enginid = $(this).find('.enginid').attr('enginid');
                    var houkoulei = $(this).find('.houkoulei').find('input').val();
                    var koufee = $(this).find('.koufee').val();
                    var kouxing = $(this).find('.kouxing').val();
                    var shoubiao = $(this).find('.shoubiao').val();
                    var explain = $(this).find('.explain').val();

                    var index = i + 1;
                    if(data.field.isturn > 0){
                        if(!koufee){
                            throw new Error('第'+index+'行，请输入本次收取');
                        }
                        if(!kouxing){
                            throw new Error('第'+index+'行，请选择收取性质');
                        }
                    }

                    qifei_list.push({
                        enginid:enginid,
                        houkoulei:houkoulei,
                        koufee:koufee,
                        kouxing:kouxing,
                        shoubiao:shoubiao,
                        explain:explain,
                    });
                });
            } catch(e) {
                $(".qifei_list_info .listerror").find('span').text(e.message);
                $(".qifei_list_info .listerror").show();
                return false;
            }
            $(".qifei_list_info .listerror").hide();
            data.field.qifei_list = qifei_list;



            data.field.files = public_upload_file_value('upload_files');
            data = parseMoney(data);


            var butValue = $(this).attr('but');

            if(data.field.isturn > 0){
                if(data.field.iskou == '是'){
                    if(!data.field.koulei){
                        facade.error("选择本次收取款项类型");return false;
                    }
                    if(parseFloat(data.field.koufee) > parseFloat(data.field.money)){
                        layer.confirm("<div class='tit'>本次收取金额大于本次到账金额，是否继续？</div><div class='exp'></div>", {
                            title:'操作确认',
                            icon: 3,
                            area:['450px','220px'],
                            btn:['确定']
                        }, function(conindex){

                            public_flow_submit(data.field, ask_flowdata_add_hou_gongyu, ask_flowdata_edit_hou_gongyu, butValue);
                        })
                    }else{
                        public_flow_submit(data.field, ask_flowdata_add_hou_gongyu, ask_flowdata_edit_hou_gongyu, butValue);
                    }
                    return false;
                }
            }



            public_flow_submit(data.field, ask_flowdata_add_hou_gongyu, ask_flowdata_edit_hou_gongyu, $(this).attr('but'));

            return false;
        });

    });




    function get_checkbox_value(dom) {
        var obj = document.getElementsByName(dom);
        var s = [];
        for (var i = 0; i < obj.length; i++) {
            if (obj[i].checked){
                s.push(obj[i].value)
            }
        }
        return s;
    }


    $('#gongjie_list').on('input propertychange','.kouben,.kouli',function () {
        $('#gongjie_list tr').each(function (i) {
            var kouben = parseValidNum($(this).find('.kouben').val());
            var kouli = parseValidNum($(this).find('.kouli').val());
            var koufee = parseFloat(kouben) + parseFloat(kouli);
            $(this).find('.koufee').val(koufee);
        });
        jisuan_koufee_all();
    });




    $('#fuwu_list,#shuifei_list,#gongjie_list,#kuaifei_list,#qifei_list').on('input propertychange','.koufee',function () {
        jisuan_koufee_all();
    });

    function jisuan_koufee_all() {
        var allkoufee = 0;

        var arr = get_checkbox_value('koulei');
        if(in_array('fuwu', arr)){
            $('#fuwu_list tr').each(function (i) {
                var koufee = parseValidNum($(this).find('.koufee').val());
                allkoufee = parseFloat(allkoufee) + parseFloat(koufee);
            });
        }
        if(in_array('shuifei', arr)){
            $('#shuifei_list tr').each(function (i) {
                var koufee = parseValidNum($(this).find('.koufee').val());
                allkoufee = parseFloat(allkoufee) + parseFloat(koufee);
            });
        }
        if(in_array('gongjie', arr)){
            $('#gongjie_list tr').each(function (i) {
                var koufee = parseValidNum($(this).find('.koufee').val());
                allkoufee = parseFloat(allkoufee) + parseFloat(koufee);
            });
        }
        if(in_array('kuaifei', arr)){
            $('#kuaifei_list tr').each(function (i) {
                var koufee = parseValidNum($(this).find('.koufee').val());
                allkoufee = parseFloat(allkoufee) + parseFloat(koufee);
            });
        }
        if(in_array('qifei', arr)){
            $('#qifei_list tr').each(function (i) {
                var koufee = parseValidNum($(this).find('.koufee').val());
                allkoufee = parseFloat(allkoufee) + parseFloat(koufee);
            });
        }
        $("#koufee").val(parseFormatNum(allkoufee,2));
    }

    function update_refresh_row_func() {
        render_date();
        render_from();
        jisuan_koufee_all();
        $.each($("#list_list").children('tr'),function (key,val) {
            $(this).children('td:first-child').html(key+1);
        });
        setTimeout(function () {
            $(".short_table_list table tbody tr").click(function () {
                $(".short_table_list table tbody tr").removeClass('line-row');
                $(".short_table_list table tbody tr").attr('sle','');
                $(this).addClass('line-row');
                $(this).attr('sle','sle');
            });
        },1000);
    }




</script>
</body>
</html>
